//
//  JBWForgetPassWordViewController.m
//  JBWDSK
//
//  Created by 崔志伟 on 2018/7/26.
//  Copyright © 2018年 崔志伟. All rights reserved.
//

#import "JBWForgetPassWordViewController.h"
#import "JBWVerificationCodeBtn.h"

@interface JBWForgetPassWordViewController ()
@property (nonatomic,strong) UIView *editBgView  ;
@property (nonatomic,strong) UITextField  * phoneTextField ;
@property (nonatomic,strong) UITextField  * passwordTextField ;
@property (nonatomic,strong) UIButton *showPasswordBtn  ;
@property (nonatomic,strong) JBWVerificationCodeBtn  * verificationCodeBtn ;
@property (nonatomic,strong) UITextField  * verificationCodeTextField ;
@property (nonatomic,strong) UIButton  * sureBtn ;
@end

@implementation JBWForgetPassWordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.bgContentViewHight = 290.0f;
     self.backTitle = @"忘记密码";
    [self setUpInputPasswordView];
    [self setUpRegisterBtn];
}
- (void)setUpInputPasswordView {
    self.editBgView = [[UIView alloc]initWithFrame:CGRectMake(20, 75, MAIN_BG_VIEW_WIDTH-40, 44*3+2)];
    self.editBgView .backgroundColor = [UIColor whiteColor];
    self.editBgView .layer.cornerRadius = 5.f;
    self.editBgView .layer.masksToBounds = YES;
    [self.bgContentView addSubview:self.editBgView ];
    
    // 手机号码
    self.phoneTextField = [[UITextField alloc]initWithFrame:CGRectMake(5, 0, CGRectGetWidth(self.editBgView .frame)-100, 44)];
    self.phoneTextField.placeholder = @"手机号码";
    self.phoneTextField.secureTextEntry = YES;
    self.phoneTextField.font =  [UIFont systemFontOfSize:13];
    [self.editBgView  addSubview:self.phoneTextField];
    self.verificationCodeBtn = [[JBWVerificationCodeBtn alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.phoneTextField.frame), 8, 90, 44-16)];
    __block JBWVerificationCodeBtn *blockBtn = self.verificationCodeBtn;
    self.verificationCodeBtn.clickblock = ^{
        [blockBtn startAnimating];
    };
    [self.editBgView  addSubview:self.verificationCodeBtn ];
    
    UIView *centerLine = [[UIView alloc]initWithFrame:CGRectMake(0, 44, CGRectGetWidth(self.editBgView .frame), 1)];
    centerLine.backgroundColor = JBW_HEX_COLOR(0xF2F2F6);
    [self.editBgView  addSubview:centerLine];
    
    
    
    //验证码
    self.verificationCodeTextField = [[UITextField alloc]initWithFrame:CGRectMake(5, 45, CGRectGetWidth(self.editBgView .frame)-10, 44)];
    self.verificationCodeTextField.font =  [UIFont systemFontOfSize:13];
    self.verificationCodeTextField.placeholder = @"验证码";
    [self.editBgView  addSubview:self.verificationCodeTextField];
    
    
    UIView *bottomLine = [[UIView alloc]initWithFrame:CGRectMake(0, 90, CGRectGetWidth(self.editBgView .frame), 1)];
    bottomLine.backgroundColor = JBW_HEX_COLOR(0xF2F2F6);
    [self.editBgView  addSubview:bottomLine];
    
    //密码
    self.passwordTextField = [[UITextField alloc]initWithFrame:CGRectMake(5, 91, CGRectGetWidth(self.editBgView .frame)-40, 44)];
    self.passwordTextField.font =  [UIFont systemFontOfSize:13];
    self.passwordTextField.placeholder = @"密码（6-20数字或字母）";
    [self.editBgView  addSubview:self.passwordTextField];
    self.showPasswordBtn = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.passwordTextField.frame), 91, 30, 44)];
    [self.showPasswordBtn setImage:GetImageNamed(@"sdk_login_ic_cansee") forState:UIControlStateNormal];
    [self.showPasswordBtn setImage:GetImageNamed(@"sdk_login_ic_nosee") forState:UIControlStateSelected];
    [self.showPasswordBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.showPasswordBtn addTarget:self action:@selector(showPasswordBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.editBgView  addSubview:self.showPasswordBtn];
    
    
    
    
    
}

-(void)setUpRegisterBtn{
    
    self.sureBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.editBgView.frame)+15, MAIN_BG_VIEW_WIDTH-40, 44)];
    self.sureBtn.backgroundColor = [UIColor orangeColor];
    [self.sureBtn setTitle:@"确定" forState:UIControlStateNormal];
    self.sureBtn .layer.cornerRadius = 5.f;
    self.sureBtn .layer.masksToBounds = YES;
    [self.sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.sureBtn addTarget:self action:@selector(registerBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.bgContentView addSubview:self.sureBtn];
    
}

- (void)showPasswordBtnAction{
    self.showPasswordBtn.selected = ! self.showPasswordBtn.selected;
    self.passwordTextField.secureTextEntry = self.showPasswordBtn.selected;
}
#pragma mark -- 注册
- (void)registerBtnAction{
    [self dismissViewControllerAnimated:NO completion:self.dismissBlock];
    
}

@end
